<template>
	<view style="background-color: #fff;">
		<view class="" v-if="PageCur=='backpack'">
			<backpack></backpack>
		</view>
		<view class="" v-if="PageCur=='goodspoor'">
			<goodspoor></goodspoor>
		</view>

		<socity v-if="PageCur=='socity'"></socity>
		<myluck v-if="PageCur=='myluck'"></myluck>
		<market v-if="PageCur=='market'"></market>




		<!-- <view class="cu-bar  foot"
			:style="{background:'url('+Imgbase+'/bottom.png) no-repeat','background-size':'100% 100%',}">
			<view class="action" @click="NavChange" data-cur="goodspoor"
				style="position: relative;background-color:transparent;">
				<view style="margin:0 auto;" :class="PageCur=='goodspoor'?'i_large':'i_small'">
					<image :src=" Imgbase+'/1zhan_g1' + [PageCur=='goodspoor'?'_cur':''] + '.png'"
						:class="PageCur=='goodspoor'?'i_large':'i_small'" style="display: inline-block;"></image>
				</view>
			</view>
			<view class="action" @click="NavChange" data-cur="backpack" style="background-color:transparent;">
				<view style="margin:0 auto;" :class="PageCur=='backpack'?'i_large':'i_small'">
					<image :src=" Imgbase+'/1zhan_g2' + [PageCur=='goodspoor'?'_cur':''] + '.png'"
						:class="PageCur=='goodspoor'?'i_large':'i_small'" style="display: inline-block;"></image>
				</view>
			</view>
			<view class="action" @click="NavChange" data-cur="socity" style="background-color:transparent;">
				<view style="margin:0 auto;" :class="PageCur=='socity'?'i_large':'i_small'">
					<image :src=" Imgbase+'/1zhan_g3' + [PageCur=='goodspoor'?'_cur':''] + '.png'"
						:class="PageCur=='goodspoor'?'i_large':'i_small'" style="display: inline-block;"></image>
				</view>
			</view>
			<view class="action" @click="NavChange" data-cur="myluck" style="background-color:transparent;">
				<view style="margin:0 auto;" :class="PageCur=='myluck'?'i_large':'i_small'">
					<image :src=" Imgbase+'/1zhan_g4' + [PageCur=='goodspoor'?'_cur':''] + '.png'"
						:class="PageCur=='goodspoor'?'i_large':'i_small'" style="display: inline-block;"></image>
				</view>
			</view>
		</view> -->
		
		
		<!-- <u-tabbar
			:value="value1"
			@change="change1"
			:placeholder="false"
			:safeAreaInsetBottom="false"
		>
			<u-tabbar-item text="首页" icon="home" @click="clicks1" ></u-tabbar-item>
			<u-tabbar-item text="放映厅" icon="photo" @click="clicks1" ></u-tabbar-item>
			<u-tabbar-item text=" " class="tabicon" icon="play-right" @click="clicks1" ></u-tabbar-item>
			<u-tabbar-item text="直播" icon="play-right" @click="clicks1" ></u-tabbar-item>
			<u-tabbar-item text="我的" icon="account" @click="clicks1" ></u-tabbar-item>
		</u-tabbar>
		 -->
		 <tabbar></tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				PageCur: 'goodspoor',
				Imgbase: getApp().globalData.Imgbase,
				personWays: '',
				timer: null,
				moveY: 200,
				moveX: 200,
				windowWidth: '',
				windowHeight: '',
				start: [0, 0],
				value1: 0,
				appid: 0,
				appphone: 0,
				id: 0,
				money: 0,
				value1: 0,
			}
		},
		onLoad(options) {
			if (options.mes != null) {
				this.getuser()
				this.PageCur = options.mes;
			}
			if (options.id) {
				uni.setStorageSync('form', 'app')
				this.getuser()
				this.PageCur = options.mes;
				this.appid = options.id;
				this.appphone = options.phone;
				this.money = options.money;
			}

			uni.setTabBarStyle({
				backgroundImage: '/static/icon.jpg',
				backgroundRepeat: 'repeat'
			})
			//this.$websocket.dispatch('WEBSOCKET_INIT', 'ws://47.103.72.180:2501')
		},
		onShow() {
			uni.hideTabBar()
			this.$forceUpdate()
			const {
				windowWidth,
				windowHeight
			} = uni.getSystemInfoSync();
			this.windowWidth = windowWidth
			this.windowHeight = windowHeight
			// this.getuser()
			// uni.setStorageSync('token','')

		},
		created() {},
		methods: {
			clicks1(e) {
				console.log('click1', e);
			},
			click1(e) {
				switch (e) {
					case 0:
						this.PageCur = 'goodspoor'
						break;
					case 1:
						this.PageCur = 'backpack'
						break;
					case 2:
						this.PageCur = 'socity'
						break;
					case 3:
						this.PageCur = 'myluck'
						break;
				}
			},
			getuser() {
				let _this = this;
				uni.request({
					//url: _this.$globals.apibase+'/api/Userways/userFrontWithLevel',
					url: _this.$globals.apibase + '/api/Userways/userFront',
					data: {
						token: uni.getStorageSync('token'),
					},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						if (res.data.code == '401') {
							uni.setStorageSync('token', '');
							// _this.$uniApi.trylogin();
							uni.navigateTo({
								url: '/pages/login/login?id=' + _this.appid + '&phone=' + _this
									.appphone + '&money=' + _this.money
							})
						}
						if (res.data.code == '1') {
							_this.id = res.data.data.user_desc.id;

							if (_this.appid != 0) {
								if (_this.appid == _this.id) {
									uni.navigateTo({
										url: '/pages/goodspoor/invest?id=' + _this.money
									})
								} else {
									uni.showToast({
										icon: 'none',
										title: 'APP账号与微信登陆账号不一致，请检查账号或更换支付方式',
										duration: 3500
									});
								}
							}
						}
					}
				});
				uni.request({
					url: _this.$globals.apibase + '/api/Minlogin/havePhoneNumber',
					data: {
						token: uni.getStorageSync('token'),
					},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						if (res.data.code == '401') {
							uni.setStorageSync('token', '');
							//_this.$uniApi.trylogin();
						}
						if (res.data.code == '1') {
							_this.phonestate = res.data.data.state;
							if (_this.phonestate == 0) {
								_this.modalName = 'getPhoneNumber';
							}
						}
					}
				});
			},
			initWebSocket() {
				let ws = new WebSocket('ws://47.103.72.180:2501')
				console.log(ws)
				ws.onopen = function() {
					console.log(123123123)
				}
			},
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur
			},
			personRun() {
				let _this = this;
				if (_this.timer == null) {
					this.personWays = 'run';
					this.timer = setInterval(() => {
						_this.personWays = '';
						clearTimeout(_this.timer);
						_this.timer = null;
					}, 8000)
				}
			},
			drag_start(event) {
				this.start[0] = event.touches[0].clientX - event.target.offsetLeft;
				this.start[1] = event.touches[0].clientY - event.target.offsetTop;
				let _this = this;
				if (_this.timer == null) {
					this.personWays = 'run';
					this.timer = setInterval(() => {
						_this.personWays = '';
						clearTimeout(_this.timer);
						_this.timer = null;
					}, 8000)
				}
			},
			drag_hmove(event) {
				let tag = event.touches;
				if (tag[0].clientX < 0) {
					tag[0].clientX = 0
				}
				if (tag[0].clientY < 0) {
					tag[0].clientY = 0
				}
				if (tag[0].clientX > this.windowWidth) {
					tag[0].clientX = this.windowWidth
				}
				if (tag[0].clientY > this.windowHeight) {
					tag[0].clientY = this.windowHeight
				}
				this.moveX = tag[0].clientX - this.start[0];
				this.moveY = tag[0].clientY - this.start[1];
			}
		},
		onReachBottom() {
			uni.$emit('onReachBottom');
		},
		//分享功能
		onShareAppMessage(res) {
			return {
				title: '欧气一番赏',
				path: '/pages/index/index',
				imageUrl: 'https://oqyf-1305090490.cos.ap-shanghai.myqcloud.com/front/1zhan_new_logo.png',
			}
		},
		//分享功能
		onShareTimeline(res) {
			return {
				title: '欧气一番赏',
				path: '/pages/index/index',
				imageUrl: this.Imgbase + '/1new_gooditem.png',
			}
		},
	}
</script>

<style lang="scss">
	.person {
		-webkit-backgroung-size: auto 120upx;
		background-color: auto 120upx;
		width: 110px;
		height: 240upx;
		margin: 0 auto;

	}

	.run {
		-webkit-animation: person 1s steps(8, start) 0ms infinite normal backwards;
		animation: person 1s steps(8, start) 0ms infinite normal backwards;
	}

	@-webkit-keyframes person {
		0% {
			background-position: 0 0;
		}

		100% {
			background-position: -781px 0;
		}
	}

	@keyframes person {
		0% {
			background-position: 0 0;
		}

		100% {
			background-position: -781px 0;
		}
	}

	.i_small {
		width: 100upx;
		height: 100upx;
		margin-top: -18upx;
	}

	.i_large {
		width: 120upx;
		height: 120upx;
		margin-top: -28upx;
	}

	.u-page__item__slot-icon {
		width: 110rpx;
	}

	image {
		will-change: transform;
		height: auto;
	}

	.u-page__item__slot-icon1 {
		width: 130rpx;
	}
	
</style>